package com.guigu.www.erp.dehao.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.guigu.www.erp.common.pojo.PageVo;
import com.guigu.www.erp.dehao.dao.RoleMapper;
import com.guigu.www.erp.dehao.pojo.Role;
import com.guigu.www.erp.dehao.service.RoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
@Transactional
public class RoleServiceImpl implements RoleService {
    @Autowired
    private RoleMapper mapper;

    @Override
    public void deleteByPrimaryKey(Integer roleId) {
        mapper.deleteByPrimaryKey(roleId);
    }

    @Override
    public void insertSelective(Role role) {
        mapper.insertSelective(role);
    }

    @Override
    public Role selectByPrimaryKey(Integer roleId) {
        return mapper.selectByPrimaryKey(roleId);
    }

    @Override
    public void updateByPrimaryKeySelective(Role role) {
        mapper.updateByPrimaryKeySelective(role);
    }

    @Override
    public PageVo<Role> findAllRole(Integer pageNum,Integer pageSize) {
        PageHelper.startPage(pageNum,pageSize);
        List<Role> allRole = mapper.findAllRole();
        PageInfo<Role> info = new PageInfo<>(allRole);
        return new PageVo<>(info.getTotal(),info.getList());
    }

    @Override
    public List<Role> findRole() {
        return mapper.findRole();
    }
}
